//
//  PersonMessageTableViewCell.m
//  MobileOffice
//
//  Created by jjkj on 16/10/25.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "PersonMessageTableViewCell.h"

@implementation PersonMessageTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //左边
        _leftHeadImageView=[[UIImageView alloc]initWithFrame:CGRectMake(8, 8, 40, 40)];
        _leftHeadImageView.image=[UIImage imageNamed:@"k_portrait@2x"];
        _leftHeadImageView.layer.masksToBounds=YES;
        _leftHeadImageView.layer.cornerRadius=_leftHeadImageView.width/2;
        [self.contentView addSubview:_leftHeadImageView];
        
        _leftNameLabel=[MyControl creatLabelWithFrame:CGRectMake(_leftHeadImageView.x, _leftHeadImageView.y+_leftHeadImageView.height, 40, 20) text:@""];
        _leftNameLabel.textAlignment=NSTextAlignmentCenter;
        _leftNameLabel.font=FONT_12;
        [self.contentView addSubview:_leftNameLabel];
        
        _leftBackView=[[UIView alloc]initWithFrame:CGRectMake(_leftHeadImageView.x+_leftHeadImageView.width+8, 8, 150,60)];
        _leftBackView.backgroundColor=[UIColor greenColor];
        _leftBackView.layer.masksToBounds=YES;
        _leftBackView.layer.cornerRadius=5;
        [self.contentView addSubview:_leftBackView];
        
        _leftMessageLabel=[MyControl creatLabelWithFrame:CGRectMake(8, 8, _leftBackView.width-16, 20) text:@""];
        _leftMessageLabel.numberOfLines=0;
        _leftMessageLabel.font=FONT_13;
        [_leftBackView addSubview:_leftMessageLabel];
        
        _leftTimeLabel=[MyControl creatLabelWithFrame:CGRectMake(8, _leftMessageLabel.y+_leftMessageLabel.height, _leftBackView.width-16, 20) text:@""];
        _leftTimeLabel.font=FONT_12;
        _leftTimeLabel.textAlignment=NSTextAlignmentRight;
        [_leftBackView addSubview:_leftTimeLabel];
        
        //右边
        _rightHeadImageView=[[UIImageView alloc]initWithFrame:CGRectMake(IPHONE_WIDTH-40-8, 8, 40, 40)];
        _rightHeadImageView.layer.masksToBounds=YES;
        _rightHeadImageView.layer.cornerRadius=_rightHeadImageView.width/2;
        _rightHeadImageView.image=[UIImage imageNamed:@"k_portrait@2x"];
        [self.contentView addSubview:_rightHeadImageView];
        
        _rightNameLabel=[MyControl creatLabelWithFrame:CGRectMake(_rightHeadImageView.x, _rightHeadImageView.y+_rightHeadImageView.height, 40, 20) text:@""];
        _rightNameLabel.textAlignment=NSTextAlignmentCenter;
        _rightNameLabel.font=FONT_12;
        [self.contentView addSubview:_rightNameLabel];
        
//        _rightBackView=[[UIView alloc]initWithFrame:CGRectMake(_rightHeadImageView.x-8-200, 8, 200,60)];
//        _rightBackView.backgroundColor=[UIColor greenColor];
//        _rightBackView.layer.masksToBounds=YES;
//        _rightBackView.layer.cornerRadius=5;
//        [self.contentView addSubview:_rightBackView];
//        
//        _rightMessageLabel=[MyControl creatLabelWithFrame:CGRectMake(8, 8, _rightBackView.width-16, 20) text:@"测试消息"];
//        _rightMessageLabel.font=FONT_13;
//        [_rightBackView addSubview:_rightMessageLabel];
//        
//        _rightTimeLabel=[MyControl creatLabelWithFrame:CGRectMake(8, _rightMessageLabel.y+_rightMessageLabel.height+8, _rightBackView.width-16, 20) text:@"2016-10-20 15:21:33"];
//        _rightTimeLabel.font=FONT_12;
//        _rightTimeLabel.textAlignment=NSTextAlignmentRight;
//        [_rightBackView addSubview:_rightTimeLabel];
        UILongPressGestureRecognizer *tapGesture= [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureClick)];
        tapGesture.minimumPressDuration=1.0;
        [self.contentView addGestureRecognizer:tapGesture];
        
    }
    return self;
}

#pragma mark -手势的响应事件
- (void)tapGestureClick{
    if (_myBlock) {
        _myBlock(self.row);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
